all: grammar compile totype

grammar: distclean
	bnfc -haskell Type.cf
compile:
	happy -gca ParType.y
	alex -g LexType.x
	latex DocType.tex
	dvips DocType.dvi -o DocType.ps
	ghc --make TestType.hs -o TestType
totype:
	ruby -pe '$$_.gsub!(/AbsType/,"Type.Parser.\\0")' -i *.hs
	ruby -pe '$$_.gsub!(/ErrM/,"Type.Parser.\\0")' -i *.hs
	ruby -pe '$$_.gsub!(/LexType/,"Type.Parser.\\0")' -i *.hs
	ruby -pe '$$_.gsub!(/ParType/,"Type.Parser.\\0")' -i *.hs
	ruby -pe '$$_.gsub!(/PrintType/,"Type.Parser.\\0")' -i *.hs
	ruby -pe '$$_.gsub!(/SkelType/,"Type.Parser.\\0")' -i *.hs
	ruby -pe '$$_.gsub!(/TestType/,"Type.Parser.\\0")' -i *.hs
clean:
	 rm -f *.log *.aux *.hi *.o *.dvi DocType.ps
distclean: clean
	 rm -f DocType.* LexType.* ParType.* ParTypeData.* LayoutType.* SkelType.* PrintType.* TestType.* AbsType.* TestType ErrM.* SharedString.* Type.dtd XMLType.*
